<!DOCTYPE >
<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>属性列表</title>


<link rel="stylesheet" type="text/css" href="/system/css/right.css">
<script type="text/javascript" src="/system/js/jquery.js"></script>
<script type="text/javascript" src="/system/js/system.js"></script>
<script type="text/javascript" src="/system/js/admin.js"></script>
<!-- 百度编辑器 -->
<script type="text/javascript" src="/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="/ueditor/ueditor.all.js"></script>
<!-- /百度编辑器 -->
<!-- 异步上传 -->
<script type="text/javascript" src="/system/js/ajaxfileupload.js" ></script>
<!-- /异步上传 -->

</head>
<body style="overflow: auto;">
	<div class="basic bor">
			<div class="title fl">当前位置：属性管理 > 属性列表</div>
	</div>
	<form action="{:url('Product/addclass')}"  enctype="multipart/form-data" method="post">
	<div class="addnav">
				<span class="navname">品牌名称：</span>
				<input class="input127" type="text" name="name" >
		<span class="navname">上级菜单：</span>
				<select name="uid" id="uid">
					<option value="0">顶级分类</option>
					{volist name="list" id="li"}
					<option value="{$li.id}">{$li.html}{$li.name}</option>
					{/volist}
				</select>
				<div class="infx blocks">
						<input class="infile" type="file"   name="pic" value="">
						<span class="text_s">品牌logo</span>
						<!-- <input type="file" name="image" /> <br> -->
						</div>
				<input class="submit addnew" type="submit" value="添加" />
		</div>
	</form>


<!-- 文章分类列表 -->
<div class="catelist">
    <div class="lists listsov">
    <dd>属性列表</dd>
    </div>

</div>
<!-- /文章分类列表 -->
<table border="1"  class="table table-hover text-center" id='list'>
  <tr class="trcolor">
    <td>ID</td>
		<td>菜单选项</td>
   	<td>名称</td>
		<td>缩略图</td>
		<td>车型列表</td>
   	<td>添加菜单</td>
    <td>操作</td>
  </tr>
<!-- ============================================================= -->
{volist name="list" id="li" key="k"}
	<tr>
		<td>{$li.id}</td>
		<td>打开</td>
		<td>{$li.html}<input type="text" calss_id = "{$li.i}" onchange="upclass({$li.id})" name="" value="{$li.name}" > </td>
		<td >
			<div class="opacity0">
				<img src="{$li.pic}" height="50"  alt="" id="img_{$k}" >
				<input type="file" name="pic" class="imputs" data-id ='{$li.id}'  data-key = "{$k}"  id="pic_{$k}" >
			</div>
		</td>
		<td>
				{if condition="$li['level'] eq 3  "}
					<a href="{:url('Product/modellist',['id'=>$li['id']])}" class="current">车型列表</a>
			{/if}
		</td>
		<td>
				{if condition="$li['level'] eq 3  "}
					<a href="{:url('Product/addlevel',['id'=>$li['id']])}" class="current">添加菜单</a>
				{/if}
		</td>
		<td><a href="{:url('Product/delclass', ['id' => $li['id']])}" class="current"  onclick="return confirm('确定将此记录删除?')" >删除</a></td>
	</tr>



{/volist}
<!-- ============================================================= -->
</table>
<script type="text/javascript">

//异步上传图片
$(function () {
			 $(".imputs").change(function () {
					 var $this = $(this);
					 var key = $this.attr('data-key');
					 var id = $this.attr("data-id");
						$.ajaxFileUpload
					 (
							 {
									 url: "{:url('Product/addclass_pic')}", //用于文件上传的服务器端请求地址
									 type: 'post',
									 data: { id: id, Key: key }, //此参数非常严谨，写错一个引号都不行
									 secureuri: false, //一般设置为false
									 fileElementId: 'pic_'+key, //文件上传空间的id属性  <input type="file" id="file" name="file" />
									 dataType: 'json', //返回值类型 一般设置为json
									 success: function (data, status)  //服务器成功响应处理函数
									 {
										 	console.info(data.imgurl);
											 if(data.status == 1){
													 $("#img_"+key).attr('src',data.imgurl);
											 }
									 },
									 error: function (data, status, e)//服务器响应失败处理函数
									 {
											 alert(e);
									 }
							 }
					 );
			 });
});

	//异步修改品牌名称
	function upclass(id){
		name = $('[calss_id='+id+']').val();
		  $.ajax({
		      type:"post",                      //请求类型
		      url:'{:url("Product/upclass")}',           //URL
		      data:{id:id,name:name},   //传递的参数
		      dataType:"json",                 //返回的数据类型
		      success:function(data){          //data就是返回的json类型的数据
						alert(data.sutart);
		      }
		  });
	}
	//异步修改所属品牌
	function upclass_uid(id){
			name = ''
		var options=$("#lvshiid_"+id+" option:selected");
    var name = options.val();
			$.ajax({
					type:"post",                      //请求类型
					url:'{:url("Product/upclass_uid")}',           //URL
					data:{id:id,name:name},   //传递的参数
					dataType:"json",                 //返回的数据类型
					success:function(data){          //data就是返回的json类型的数据
					  window.location.href='{:url("product/classlist")}';
					}
			});
	}


</script>

<style>
.hide{
	display: hide;
}
</style>
</body>
</html>
